<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCommissionDetailsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('commission_details', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('user_id')      ->default(0)->comment('返成接受者');
            $table->bigInteger('from_user_id') ->default(0)->comment('返成贡献者');
            $table->string('order_num')         ->nullable()->comment('订单号');
            $table->string('order_created_at')  ->nullable()->comment('订单创建时间');
            $table->decimal('pay_amount')       ->default(0)->comment('实际付款');
            $table->string('distribution_nickname')->default('')->comment('分销商昵称');
            $table->string('distribution_level')->default('')->comment('分销商等级');
            $table->integer('level')        ->nullable()->comment('等级:1,2,3级');
            $table->integer('type')         ->default(0)->comment('类型:1新增，2提现');
            $table->decimal('amount')       ->default(0)->comment('金额');
            $table->string('withdrawal_num') ->default('')->comment('提现单号');
            $table->decimal('rate')         ->default(0)->comment('佣金比率');
            $table->integer('status')       ->default(0)->comment('结算状态：0待结算，1已到账，2已撤销');
            $table->timestamp('arrival_time') ->nullable()->comment('到账时间');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('commission_details');
    }
}
